package com.toy.core.client.impl;

import org.springframework.stereotype.Service;

import com.google.common.base.Optional;
import com.toy.core.client.SecurityService;
import com.toy.core.security.Authentication;
import com.toy.core.security.context.SecurityContextHolder;

@Service("securityService")
public class SecurityServiceImpl implements SecurityService {

	public String getCurrentUsername() {
		Authentication auth =  SecurityContextHolder.getContext().getAuthentication();
		return (String)Optional.fromNullable(auth).get().getPrincipal();
	}

}
